/**
 * Created by kangli on 2018/3/26.
 */
var sum;
var counts = '';
var pageThis = 0;
var pagecount = 15;
var index = 0;
var bookDetailLists = '';
var requiredElective = 'REQUIRED';// 默认必修课
var schoolLists = '';
var courseLists = '';
var gongyearNum = '';
var gongScoolName = '';
var chooseSchoolName = '';
var keyword = '';//关键字
var coursesOffered = '';
var education = '';
var duties = '';
var positional = '';
var starttime = '';
var endtime = '';
var weekday = '';
var bookid = '';
var proname = '';
var exportExcelUrl1 = BasePath + "schoolInfo/exportgetSchoolDetials";
var exportExcelUrl2 = BasePath + "schoolInfo/exportgetSchoolInfo";
var exportExcelUrl3 = BasePath + "schoolInfo/exportsearchClass";
var exportExcelUrl4 = BasePath + "schoolInfo/exportTeacher";
var exportExcelUrl5 = BasePath + "schoolInfo/exportCourse";
var exportExcelUrl6 = BasePath + "schoolInfo/exportBookson";
var exportExcelUrl7 = BasePath + "schoolInfo/exportPracticeTeaching";
/* $.ajaxSetup({ async: false }); */
var objectList = ''
$(function () {
    getSchoolName();
    $(".must").click(function () {
        $(this).addClass("span-red").siblings().removeClass("span-red");
        $(".table_must").removeClass("hide");
        $(".table_may").addClass("hide");
        requiredElective = 'REQUIRED';// 在教材使用中是必修课
        getBookInfo();
    });
    $(".may").click(function () {
        $(this).addClass("span-red").siblings().removeClass("span-red");
        $(".table_may").removeClass("hide");
        $(".table_must").addClass("hide");
        requiredElective = 'ELECTIVE';// 在教材使用中是选修课
        getBookInfo2();
    });
    getTeacherInfo();// 得到教师信息
    getCourseInfo();// 得到课表信息
    getBookInfo();// 得到教材使用信息
    getsearchPracticeInfo();// 得到实践活动
    getSchoolTecherInfo();// 得到学校教师人数
    getSchoolClassInfo();// 得到学校班级信息
    getSchoolInfo();// 得到学校基本信息

    /*导出字段实体类*/
    objectList = {
        "1": {
            "schoolName": "学校",
            "buildType": "类型",
            "graduateStudent": "本/专科生",
            "masterNum": "硕士",
            "doctorNum": "博士",
            "allTeacher": "思政教师",
            "requiredCourse": "必修课",
            "electiveCourse": "选修课",
            "practiceTeachingcount": "实践活动",
            "masterPosNum": "硕士点",
            "doctorPosNum": "博士点",
            "lastUpdateTime": "更新时间"
        },
        "2": {
            "schoolName": "学校",
            "allTeacher": "思政教师",
            "professorNum": "教授",
            "associateProfessorNum": "副教授",
            "lecturerNum": "讲师",
            "doctorNum": "博士",
            "masterNum": "硕士生",
            "graduateStudent": "本科生",
            "averageClassTime": "学年平均课时",
            "averageClassNumber": "学年平均班级人数"
        },
        "3": {
            "schoolName": "学校",
            "claaAllNum": "学校班级总数",
            "count1": "100人以上班级数",
            "count2": "60-90人班级数",
            "count3": "60人以下班级数"
        },
        "4": {
            "teacherName": "教师名",
            "schoolName": "学校",
            "positional": "职称",
            "duties": "职务",
            "phone": "联系电话",
            "coursesOffered": "主授课程",
            "researchDirection": "研究方向",
            "researchFindings": "研究成果",
            "awardWinning": "获奖情况",
            "schoolyear": "学年课时"
        },
        "5": {
            "schoolName": "学校",
            "courseName": "课程",
            "requiredElective": "必/选修课",
            "teacher": "上课教师",
            "classPlace": "上课地点",
            "startTime": "开课日期",
            "classTime": "上课时间",
            "credit": "学分",
            "choiceOfCoursesNumber": "选课人数",
            "isGraduateClazz": "是否研究生课程"
        },
        "6": {
            "schoolName": "学校",
            "bookName": "教材名称",
            "outOfTheSociety": "出版社",
            "useVersion": "版本",
            "userNumber": "使用人数"
        },
        "7": {
            "projectName": "活动名称",
            "teacher": "带队教师",
            "studentNum": "参与人数",
            "credit": "学分",
            "date": "活动日期",
            "content": "活动内容"
        },
        "8": {
            "schoolName": "学校",
            "className": "课程名称",
            "classTeacher": "上课教师",
            "bookName": "教材名称",
            "outOfTheSociety": "出版社",
            "editor": "主编",
            "useVersion": "版本",
            "isMarxProject": "是否属于马工程",
            "userNumber": "使用人数"
        }
    }
});
// 改变一页几条
function changePage(btn) {
    pagecount = $(btn).attr("data-num");
    var numPage = $(btn).parent().parent().prev().parent().prev().parent().attr("id");
    $(btn).parent().prev().text(pagecount + '条/页');
    if (numPage == 'firstPage') {
        getSchoolInfo();
    } else if (numPage == 'secondPage') {
        getSchoolTecherInfo();
    } else if (numPage == 'thirdPage') {
        getSchoolClassInfo();
    } else if (numPage == 'forthPage') {
        console.log(pagecount)
        getTeacherInfo();
    } else if (numPage == 'fifthPage') {
        getCourseInfo();
    } else if (numPage == 'sixthhPage') {
        getBookInfo();
    } else if (numPage == 'seventhhPage') {
        getsearchPracticeInfo();
    }

}
// 搜索学校基本信息
function searchBasicInfo(btn) {
    index = 0;
    gongyearNum = $(".CourseSchoolYear").eq(0).children("option:selected").attr("data-yearnum");
    gongScoolName = $(".searchName1").val() || '';
    getSchoolInfo();
}
// 搜索学校教师信息
function searcSchoolTeaInfo(btn) {
    index = 0;
    gongyearNum = $(".CourseSchoolYear").eq(1).children("option:selected").attr("data-yearnum");
    gongScoolName = $(".searchName2").val() || '';
    getSchoolTecherInfo();
}
// 搜索学校班级
function searchSchoolClassInfo(btn) {
    index = 0;
    gongyearNum = $(".CourseSchoolYear").eq(2).children("option:selected").attr("data-yearnum");
    gongScoolName = $(".searchName3").val() || '';
    getSchoolClassInfo();
}
// 搜索教师信息需修改
function searchTeacherInfo(btn) {
    index = 0;
    chooseSchoolName = $(".schoolSelect").eq(0).children("option:selected").attr("data-schoolId");
    education = $(".educationSelect").children("option:selected").attr("data-typeT");
    duties = $(".dutiesSelect").children("option:selected").attr("data-typeT");
    positional = $(".positionalSelect").children("option:selected").attr("data-typeT");
    coursesOffered = $(".courseSelect").children("option:selected").attr("data-courseId");
    keyword = $(".keyWord").val() || '';
    getTeacherInfo();
}
// 搜索课表信息需修改
function searchCourseInfo(btn) {
    index = 0;
    gongyearNum = $(".CourseSchoolYear").eq(3).children("option:selected").attr("data-yearnum");
    gongScoolName = $(".searchName4").val() || '';
    starttime = $("#startTime").val() || '';
    endtime = $("#endTime").val() || '';
    weekday = $(".weekday").children("option:selected").text();
    weekday = weekday === "全部" ? "" : weekday;
    /*
     * console.log(starttime) console.log(endtime)
     */
    getCourseInfo();
}
// 搜索教材使用
function searchBookInfo(btn) {
    index = 0;
    if ($(".must").hasClass("span-red")) {// 必修课
        gongyearNum = $(".CourseSchoolYear1").eq(0).children("option:selected").attr("data-yearnum");
        chooseSchoolName = $(".schoolSelect").eq(1).children("option:selected").attr("data-schoolId");
        bookid = $(".BookSelect").children("option:selected").attr("data-bookId")
        getBookInfo();
    }
    else if ($(".may").hasClass("span-red")) {// 选修课
        gongyearNum = $(".CourseSchoolYear1").eq(0).children("option:selected").attr("data-yearnum");
        gongScoolName = $(".schoolSelect").eq(1).children("option:selected").attr("data-schoolId");
        bookid = $(".BookSelect").children("option:selected").attr("data-bookId")
        getBookInfo2();
    }
}
// 搜索实践活动需修改
function searchPracticeInfo(btn) {
    index = 0;
    chooseSchoolName = $(".schoolSelect").eq(2).children("option:selected").attr("data-schoolId");
    /* console.log(chooseSchoolName); */
    starttime = $(".activityStart").val();
    endtime = $(".activityEnd").val();
    proname = $(".proname").val();
    getsearchPracticeInfo();
}

// 得到学校教师人数
function getSchoolTecherInfo() {
    getSchoolYear();
    var data = '{"page":"' + index + '","size":"' + pagecount + '","schoolName":"' + gongScoolName + '"}';
    console.log(data)
    AjaxSubmit("GET", JSON.parse(data), BasePath + "schoolInfo/searchSchool", searchAllSchool_fun1);
}
function searchAllSchool_fun1(res) {
    console.log(res);
    if (res.status == 'SUCCESS') {
        var allschoolLists = res.obj.content;
        sum = res.obj.totalElements;
        counts = sum / pagecount;
        if (allschoolLists.length != 0) {
            $(".schoolTeaTbody").show();
            $(".schoolTeaPage").css("display", "block");
            if (sum % pagecount == 0) {
                counts = parseInt(sum / pagecount);
            }
            else {
                counts = parseInt(sum / pagecount) + 1;
            }
            $(".schoolTeaPage").paging({
                pageNo: pageThis,
                totalPage: counts,
                totalSize: sum,
                callback: function (num) {
                    console.log(num);
                    index = num - 1;
                    getSchoolTecherInfo();
                    pageThis = num;
                }
            });
            $(".schoolTeaTbody").empty();
            $.each(allschoolLists, function (i, allschoolList) {
                var schoolid = allschoolList.id;
                gongyearNum = $(".CourseSchoolYear").eq(1).children("option:selected").attr("data-yearnum");
                var data = '{"id":"' + schoolid + '","yearNum":"' + gongyearNum + '"}';
                console.log(data);
                var html = $('<tr class="' + allschoolList.id + '"> ' +
                    '<td >' + allschoolList.schoolName + '</td> ' + AjaxSubmit("GET", JSON.parse(data), BasePath + "schoolInfo/getSchoolInfo", getSchoolInfo_fun, allschoolList.id) +
                    '</tr>');
                $(".schoolTeaTbody").append(html);

                /* AjaxSubmit("GET", JSON.parse(data), BasePath + "schoolInfo/getSchoolInfo", getSchoolInfo_fun);*/
                function getSchoolInfo_fun(res, extr1) {
                    console.log(res);
                    if (res.code == "1001") {
                        return;
                    }
                    $(".warnDiv3").remove();
                    var professorNumPercent = ((res.obj.allTeacher == 0) ? "无" : ((((res.obj.professorNum / res.obj.allTeacher) * 100).toFixed(2)) + "%"));
                    var associateProfessorNumPercent = ((res.obj.allTeacher == 0) ? "无" : ((((res.obj.associateProfessorNum / res.obj.allTeacher) * 100).toFixed(2)) + "%"));
                    var lecturerNumPercent = ((res.obj.allTeacher == 0) ? "无" : ((((res.obj.lecturerNum / res.obj.allTeacher) * 100).toFixed(2)) + "%"));
                    var doctorNumPercent = ((res.obj.allTeacher == 0) ? "无" : (((res.obj.doctorNum / (res.obj.allTeacher) * 100).toFixed(2)) + "%"));
                    var masterNumPercent = ((res.obj.allTeacher == 0) ? "无" : (((res.obj.masterNum / (res.obj.allTeacher) * 100).toFixed(2)) + "%"));
                    var graduateStudentPercent = ((res.obj.allTeacher == 0) ? "无" : (((res.obj.graduateStudent / (res.obj.allTeacher) * 100).toFixed(2)) + "%"));
                    var averageClassTime = ((res.obj.allTeacher == 0) ? "无" : parseInt((res.obj.averageClassTime) / (res.obj.allTeacher)));
                    var html = $(
                        '<td>' + res.obj.allTeacher + '</td> ' +
                        '<td>' + res.obj.professorNum + '</td> ' +
                        '<td>' + professorNumPercent + '</td> ' +
                        '<td>' + res.obj.associateProfessorNum + '</td> ' +
                        '<td>' + associateProfessorNumPercent + '</td> ' +
                        '<td>' + res.obj.lecturerNum + '</td> ' +
                        '<td style="border-right:1px solid #ddd">' + lecturerNumPercent + '</td> ' +
                        '<td>' + res.obj.doctorNum + '</td> ' +
                        '<td>' + doctorNumPercent + '</td> ' +
                        '<td>' + res.obj.masterNum + '</td> ' +
                        '<td>' + masterNumPercent + '</td> ' +
                        '<td>' + res.obj.graduateStudent + '</td> ' +
                        '<td>' + graduateStudentPercent + '</td> ' +
                        '<td>' + averageClassTime + '</td> ' +
                        '<td>' + res.obj.averageClassNumber + '</td>');
                    $("." + extr1).append(html);
                }

            });
        }
        else {
            $(".schoolTeaPage").css("display", "none");
            $(".schoolTeaTbody").hide();
            $(".warnDiv3").remove();
            var html1 = $('<div class="text-center warnDiv3" style="width: 100%;margin: 73px 0px;font-size: 14px" >无信息!</div>');
            $(".schoolTeaTable").after(html1)
        }
    }
}

// 得到学校班级信息
function getSchoolClassInfo() {
    getSchoolYear();
    var data = '{"page":"' + index + '","size":"' + pagecount + '","schoolName":"' + gongScoolName + '"}';
    AjaxSubmit("GET", JSON.parse(data), BasePath + "schoolInfo/searchSchool", searchAllSchool_fun2);
}

function searchAllSchool_fun2(res) {
    /* console.log(res); */
    if (res.status == 'SUCCESS') {
        var allschoolLists = res.obj.content;
        sum = res.obj.totalElements;
        counts = sum / pagecount;
        if (allschoolLists.length != 0) {
            $(".schoolClassTbody").show();
            $(".schoolClassPage").css("display", "block");
            if (sum % pagecount == 0) {
                counts = parseInt(sum / pagecount);
            }
            else {
                counts = parseInt(sum / pagecount) + 1;
            }
            $(".schoolClassPage").paging({
                pageNo: pageThis,
                totalPage: counts,
                totalSize: sum,
                callback: function (num) {
                    console.log(num);
                    index = num - 1;
                    getSchoolClassInfo();
                    pageThis = num;
                }
            });
            $(".schoolClassTbody").empty();
            $.each(allschoolLists, function (i, allschoolList) {
                var schoolid = allschoolList.id;
                gongyearNum = $(".CourseSchoolYear").eq(2).children("option:selected").attr("data-yearnum");
                var data = '{"id":"' + schoolid + '","yearNum":"' + gongyearNum + '"}';
                console.log(data)
                var html = $('<tr class="' + allschoolList.id + 'nan"> ' +
                    '<td >' + allschoolList.schoolName + '</td> ' + AjaxSubmit("GET", JSON.parse(data), BasePath + "schoolInfo/searchClass", searchClass_fun, allschoolList.id) +
                    '</tr>');
                $(".schoolClassTbody").append(html);
                // AjaxSubmit("GET", JSON.parse(data), BasePath + "schoolInfo/searchClass", searchClass_fun);
                function searchClass_fun(res, extr2) {
                    console.log(res);
                    $(".warnDiv2").remove();
                    var countPercent1 = (((res.obj.count1 + res.obj.count2 + res.obj.count3) == 0) ? "无" : (((res.obj.count1 / (res.obj.count1 + res.obj.count2 + res.obj.count3) * 100).toFixed(2)) + "%"));
                    var countPercent2 = (((res.obj.count1 + res.obj.count2 + res.obj.count3) == 0) ? "无" : (((res.obj.count2 / (res.obj.count1 + res.obj.count2 + res.obj.count3) * 100).toFixed(2)) + "%"));
                    var countPercent3 = (((res.obj.count1 + res.obj.count2 + res.obj.count3) == 0) ? "无" : (((res.obj.count3 / (res.obj.count1 + res.obj.count2 + res.obj.count3) * 100).toFixed(2)) + "%"));
                    var html = $(
                        '<td>' + res.obj.claaAllNum + '</td> ' +
                        '<td>' + res.obj.count1 + '</td> ' +
                        '<td>' + countPercent1 + '</td> ' +
                        '<td>' + res.obj.count2 + '</td> ' +
                        '<td>' + countPercent2 + '</td> ' +
                        '<td>' + res.obj.count3 + '</td> ' +
                        '<td>' + countPercent3 + '</td>');
                    $("." + (extr2 + "nan")).append(html);
                }

            });
        }
        else {
            $(".schoolClassPage").css("display", "none");
            $(".schoolClassTbody").hide();
            $(".warnDiv2").remove();
            var html1 = $('<div class="text-center warnDiv2 " style="width: 100%;margin: 73px 0px;font-size: 14px" >无信息!</div>');
            $(".schoolClassTable").after(html1)
        }
    }
}

// 得到学校基本信息
function getSchoolInfo() {
    getSchoolYear();

    var data = '{"page":"' + index + '","size":"' + pagecount + '","schoolName":"' + gongScoolName + '"}';
    console.log(data);
    AjaxSubmit("GET", JSON.parse(data), BasePath + "schoolInfo/searchSchool", searchAllSchool_fun);
}
function searchAllSchool_fun(res) {
    console.log(res);
    if (res.status == 'SUCCESS') {
        var allschoolLists = res.obj.content;
        sum = res.obj.totalElements;
        counts = sum / pagecount;
        if (allschoolLists.length != 0) {
            $(".schoolTbody").show();
            $(".allschoolPage").css("display", "block");
            if (sum % pagecount == 0) {
                counts = parseInt(sum / pagecount);
            }
            else {
                counts = parseInt(sum / pagecount) + 1;
            }
            $(".allschoolPage").paging({
                pageNo: pageThis,
                totalPage: counts,
                totalSize: sum,
                callback: function (num) {
                    console.log(num);
                    index = num - 1;
                    getSchoolInfo();
                    pageThis = num;
                }
            });
            $(".schoolTbody").empty();
            $(".warnDiv").remove();
            $.each(allschoolLists, function (i, allschoolList) {
                var schoolid = allschoolList.id;
                gongyearNum = $(".CourseSchoolYear").eq(0).children("option:selected").attr("data-yearnum");
                var data = '{"id":"' + schoolid + '","yearNum":"' + gongyearNum + '"}';
                console.log(data);
                var html = $('<tr id="' + allschoolList.id + '"> ' +
                    '<td >' + allschoolList.schoolName + '</td> ' + AjaxSubmit("GET", JSON.parse(data), BasePath + "schoolInfo/searchSchoolDetials", searchSchoolDetails_fun, allschoolList.id) +
                    '</tr>');
                $(".schoolTbody").append(html);
                // AjaxSubmit("GET", JSON.parse(data), BasePath + "schoolInfo/searchSchoolDetials", searchSchoolDetails_fun);
                function searchSchoolDetails_fun(ress, extr) {
                    console.log(ress);
                    var time = changeTimeXinXi(ress.obj.lastUpdateTime) || '';
                    var call = '';
                    var schooltype = '';
                    var masterPosNum = '';
                    var doctorPosNum = '';
                    if (ress.obj.graduateStudent == '0') {
                        call = '提醒'
                    } else {
                        call = '已更新'
                    }
                    if (allschoolList.type == "UNDER_GRADUATE") {
                        schooltype = '本科'
                        masterPosNum = ress.obj.masterPosNum;
                        doctorPosNum = ress.obj.doctorPosNum;
                    } else if (allschoolList.type == "SPECIALTY") {
                        schooltype = '专科'
                        masterPosNum = '无';
                        doctorPosNum = '无';
                    }
                    var theAddhtml = "";
                    if (ress.obj.allTeacher != 0 && ress.obj.allTeacher != undefined && ress.obj.allTeacher != null) {
                        theAddhtml = "1/" + (parseInt(ress.obj.graduateStudent / ress.obj.allTeacher));
                    } else {
                        theAddhtml = "无";
                    }
                    var html = $(
                        '<td>' + schooltype + '</td> ' +
                        '<td>' + ress.obj.graduateStudent + '</td> ' +
                        '<td>' + ress.obj.masterNum + '</td> ' +
                        '<td>' + ress.obj.doctorNum + '</td> ' +
                        '<td>' + ress.obj.allTeacher + '</td> ' +
                        '<td style="width: 80px">' + theAddhtml + '</td> ' +
                        '<td>' + ress.obj.requiredCourse + '</td> ' +
                        '<td>' + ress.obj.electiveCourse + '</td> ' +
                        '<td>' + ress.obj.practiceTeachingcount + '</td> ' +
                        '<td>' + masterPosNum + '</td> ' +
                        '<td>' + doctorPosNum + '</td>' +
                        '<td>' + time + '</td> ' +
                        '<td onclick=tiXing("' + schoolid + '")><a href="javascript:;">' + call + '</a></td> '
                    );
                    $("#" + extr).append(html);
                }

            });
        }
        else {
            $(".allschoolPage").css("display", "none");
            $(".schoolTbody").hide();
            $(".warnDiv").remove();
            var html1 = $('<div class="text-center warnDiv" style="width: 100%;margin: 73px 0px;font-size: 14px" >无信息!</div>');
            $(".schoolTable").after(html1);

        }
    }
}

function tiXing(schoolId) {
    var data = {
        schoolId: schoolId
    };

    AjaxSubmit("POST", data, BasePath + "schoolInfo/sendTiXing", tiXingRes);
}
function tiXingRes(res) {
    if (res.obj == "SUCCESS") {
        alert("提醒成功！");
    }
}

// 得到教师信息
function getTeacherInfo() {
    getSchoolName();
    getCourseName();
    var data = '{"page":"' + index + '","size":"' + pagecount + '","education":"' + education + '","duties":"' + duties + '","positional":"' + positional + '","coursesOffered":"' + coursesOffered + '","schoolId":"' + chooseSchoolName + '","field1":"' + keyword + '"}';
    console.log(data)
    AjaxSubmit("GET", juge(JSON.parse(data)), BasePath + "schoolInfo/searchTeacher", searchTeacher_fun);
}
function searchTeacher_fun(res) {
    console.log(res)
    if (res.status == 'SUCCESS') {
        var teacherLists = res.obj.content;
        sum = res.obj.totalElements;
        counts = sum / pagecount;
        if (teacherLists.length != 0) {
            $(".teacherTbody").show();
            $(".teacherPage").css("display", "block");
            if (sum % pagecount == 0) {
                counts = parseInt(sum / pagecount);
            }
            else {
                counts = parseInt(sum / pagecount) + 1;
            }
            $(".teacherPage").paging({
                pageNo: pageThis,
                totalPage: counts,
                totalSize: sum,
                callback: function (num) {
                    console.log(num);
                    index = num - 1;
                    getTeacherInfo();
                    pageThis = num;
                }
            });

            $(".teacherTbody").empty();
            $(".warnDiv7").remove();
            $.each(teacherLists, function (i, teacherList) {
                if (teacherList.type == "TEACHER" || teacherList.type == "INSTRUCTOR") {
                    var teacherPosition = '';
                    var teacherDuties = '';
                    /* 职称分批 */
                    if (teacherList.positional == "LECTURER") {
                        teacherPosition = '讲师'
                    } else if (teacherList.positional == "ASSOCIATE_PROFESSOR") {
                        teacherPosition = '副教授'
                    } else if (teacherList.positional == "PROFESSOR") {
                        teacherPosition = '教授'
                    }
                    /* 职务分批 */
                    if (teacherList.duties == "YUAN_ZHANG") {
                        teacherDuties = '院长'
                    } else if (teacherList.duties == "FU_YUAN_ZHANG") {
                        teacherDuties = '副院长'
                    } else if (teacherList.duties == "SHU_JI") {
                        teacherDuties = '书记'
                    } else if (teacherList.duties == "FU_SHU_JI") {
                        teacherDuties = '副书记'
                    } else if (teacherList.duties == "KE_YAN_SHI_ZHU_REN") {
                        teacherDuties = '科研室主任'
                    } else if (teacherList.duties == "XUE_KE_DAI_TOU_REN") {
                        teacherDuties = '学科带头人'
                    } else if (teacherList.duties == "IDEOLOGICAL_POLITICAL") {
                        teacherDuties = '思政老师'
                    }
                    var phone = teacherList.phone || '';
                    var coursesOffered = teacherList.coursesOffered || '';
                    var researchDirection = teacherList.researchDirection || '';
                    if (teacherList.schoolId == '0') {
                        var html = $('<tr> ' +
                            '<td><a  data-target="#myModalteachermes" data-teaid="' + teacherList.id + '" onclick="showteacher(this)">' + teacherList.teacherName + '</a></td> ' +
                            '<td>教育厅</td> ' +
                            '<td>' + teacherPosition + '</td> ' +
                            '<td>' + teacherDuties + '</td> ' +
                            '<td>' + phone + '</td> ' +
                            '<td>' + coursesOffered + '</td> ' +
                            '<td>' + researchDirection + '</td> </tr>');
                        $(".teacherTbody").append(html)

                    } else {
                        var data1 = '{"schoolId":"' + parseInt(teacherList.schoolId) + '"}';
                        AjaxSubmit("GET", JSON.parse(data1), BasePath + "schoolInfo/getSchoolBySchoolId", searchSchool3_fun);
                        function searchSchool3_fun(schoolres) {
                            var html = $('<tr> ' +
                                '<td><a  data-target="#myModalteachermes" data-teaid="' + teacherList.id + '" onclick="showteacher(this)">' + teacherList.teacherName + '</a></td> ' +
                                '<td>' + schoolres.obj.schoolName + '</td> ' +
                                '<td>' + teacherPosition + '</td> ' +
                                '<td>' + teacherDuties + '</td> ' +
                                '<td>' + phone + '</td> ' +
                                '<td>' + coursesOffered + '</td> ' +
                                '<td>' + researchDirection + '</td> </tr>');
                            $(".teacherTbody").append(html)
                        }

                    }
                }
            });
        }
        else {
            $(".teacherPage").css("display", "none");
            $(".teacherTbody").hide();
            $(".warnDiv7").remove();
            var html1 = $('<div class="text-center warnDiv7 " style="width: 100%;margin: 73px 0px;font-size: 14px" >无信息!</div>');
            $(".teacherTable").after(html1)
        }
    }
}

// 得到实践活动
function getsearchPracticeInfo() {
    getSchoolName();
    var data = {
        page: index,
        size: pagecount,
        schoolId: chooseSchoolName,
        date: starttime,
        dateTo: endtime,
        projectName: proname
    };
    var truedata1 = juge(data);
    console.log(truedata1)
    AjaxSubmit("GET", truedata1, BasePath + "schoolInfo/searchPracticeTeaching", searchPracticeTeaching_fun);
}
function searchPracticeTeaching_fun(res) {
    console.log(res);
    if (res.status == 'SUCCESS') {
        var practicLists = res.obj.content;
        sum = res.obj.totalElements;
        counts = sum / pagecount;
        if (practicLists.length != 0) {
            $(".practiceTbody").show();
            $(".shiJianPage").css("display", "block");
            if (sum % pagecount == 0) {
                counts = parseInt(sum / pagecount);
            }
            else {
                counts = parseInt(sum / pagecount) + 1;
            }
            $(".shiJianPage").paging({
                pageNo: pageThis,
                totalPage: counts,
                totalSize: sum,
                callback: function (num) {
                    console.log(num);
                    index = num - 1;
                    getsearchPracticeInfo();
                    pageThis = num;
                }
            });
            $(".practiceTbody").empty();
            $(".warnDiv5").remove();
            $.each(practicLists, function (i, practicList) {
                var html = $('<tr> ' +
                    '<td>' + practicList.projectName + '</td> ' +
                    '<td>' + practicList.teacher + '</td> ' +
                    '<td>' + practicList.studentNum + '</td> ' +
                    '<td>' + practicList.credit + '</td> ' +
                    '<td>' + changeTime(practicList.date) + '</td> <td class="max-wid">' + practicList.content + '</td> </tr>');
                $(".practiceTbody").append(html)
            });
        }
        else {
            $(".shiJianPage").css("display", "none");
            $(".practiceTbody").hide();
            $(".warnDiv5").remove();
            var html = $('<div class="text-center warnDiv5" style="width: 100%;margin: 73px 0px;font-size: 14px" >无信息!</div>');
            $(".practiceTable").after(html)
        }
    }
}

// 得到课表信息
function getCourseInfo() {
    getSchoolYear2();
    gongyearNum = $(".CourseSchoolYear").eq(3).children("option:selected").attr("data-yearnum");
    var data = '{"page":"' + index + '","size":"' + pagecount + '","schoolYearNum":"' + gongyearNum + '","schoolId":"' + chooseSchoolName + '","startTime":"' + starttime + '","startTimeTo":"' + endtime + '","classTime":"' + weekday + '"}';
    console.log(data);
    var truedata = juge(JSON.parse(data));
    console.log(truedata);
    AjaxSubmit("GET", truedata, BasePath + "schoolInfo/searchCourse", searchCourse_fun);
}

function searchCourse_fun(res) {
    console.log(res);
    if (res.status == 'SUCCESS') {
        courseLists = res.obj.content;
        sum = res.obj.totalElements;
        counts = sum / pagecount;
        if (courseLists.length != 0) {
            $(".courseBody").show();
            $(".coursePage").css("display", "block");
            if (sum % pagecount == 0) {
                counts = parseInt(sum / pagecount);
            }
            else {
                counts = parseInt(sum / pagecount) + 1;
            }
            $(".coursePage").paging({
                pageNo: pageThis,
                totalPage: counts,
                totalSize: sum,
                callback: function (num) {
                    console.log(num);
                    index = num - 1;
                    getCourseInfo();
                    pageThis = num;
                }
            });
            $(".courseBody").empty();
            $(".warnDiv6").remove();
            $.each(courseLists, function (i, courseList) {
                var data = '{"schoolId":"' + courseList.schoolId + '"}';
                console.log(data)
                AjaxSubmit("GET", JSON.parse(data), BasePath + "schoolInfo/getSchoolBySchoolId", searchSchool2_fun);
                function searchSchool2_fun(resss) {
                    var isrequired = '';
                    var isgradute = ''
                    if (courseList.requiredElective == 'REQUIRED') {
                        isrequired = '必修课'
                    } else if (courseList.requiredElective == 'ELECTIVE') {
                        isrequired = '选修课'
                    }
                    if (courseList.isGraduateClazz == "0") {
                        isgradute = '否'
                    } else {
                        isgradute = '是'
                    }
                    var html = $('<tr> ' +
                        '<td>' + resss.obj.schoolName + '</td> ' +
                        '<td>' + courseList.courseName + '</td> ' +
                        '<td>' + isrequired + '</td> ' +
                        '<td><a data-target="#myModalteachermes" data-teaid="' + courseList.teacher + '" onclick="showteacherbyteachername(this)">' + courseList.teacher + '</a></td> ' +
                        '<td>' + courseList.classPlace + '</td> ' +
                        '<td>' + changeTimeXinXi(courseList.startTime) + '</td> ' +
                        '<td>' + courseList.classTime + '</td> ' +
                        '<td>' + courseList.credit + '</td> ' +
                        '<td>' + courseList.choiceOfCoursesNumber + '</td> ' +
                        '<td>' + isgradute + '</td> </tr>');
                    $(".courseBody").append(html)
                }

            });
        }
        else {
            $(".coursePage").css("display", "none");
            $(".courseBody").hide();
            $(".warnDiv6").remove();
            var html = $('<div class="text-center  warnDiv6" style="width: 100%;margin: 73px 0px;font-size: 14px" >无信息!</div>');
            $(".courseTable").after(html)
        }
    }

}

// 得到教材使用信息必修课
function getBookInfo() {
    getSchoolYear3();
    getBook();
    getSchoolName();
    gongyearNum = $(".CourseSchoolYear1").eq(0).children("option:selected").attr("data-yearnum");
    var data = '{"page":"' + index + '","size":"' + pagecount + '","requiredElective":"' + requiredElective + '","schoolId":"' + chooseSchoolName + '","bookId":"' + bookid + '","schoolYearNum":"' + gongyearNum + '"}';
    console.log(juge(JSON.parse(data)))
    AjaxSubmit("GET", juge(JSON.parse(data)), BasePath + "schoolInfo/searchBookson", searchBookson_fun);
}
// 得到教材使用信息选修课
function getBookInfo2() {
    getSchoolYear3();
    getBook();
    getSchoolName();
    gongyearNum = $(".CourseSchoolYear1").eq(0).children("option:selected").attr("data-yearnum");
    var data = '{"page":"' + index + '","size":"' + pagecount + '","requiredElective":"' + requiredElective + '","schoolId":"' + chooseSchoolName + '","bookId":"' + bookid + '","schoolYearNum":"' + gongyearNum + '"}';
    console.log(data)
    AjaxSubmit("GET", JSON.parse(data), BasePath + "schoolInfo/searchBookson", searchBookson_fun2);
}

// 得到教材使用信息必修课
function searchBookson_fun(res) {
    console.log(res);
    if (res.status == 'SUCCESS') {
        var bookLists = res.obj.content;
        sum = res.obj.totalElements;
        counts = sum / pagecount;
        if (bookLists.length != 0) {
            $(".bookTbody").show();
            $(".bookPage").css("display", "block");
            if (sum % pagecount == 0) {
                counts = parseInt(sum / pagecount);
            }
            else {
                counts = parseInt(sum / pagecount) + 1;
            }
            $(".bookPage").paging({
                pageNo: pageThis,
                totalPage: counts,
                totalSize: sum,
                callback: function (num) {
                    console.log(num);
                    index = num - 1;
                    getBookInfo();
                    pageThis = num;
                }
            });
            $(".bookTbody").empty();
            $(".BooknoInfo").empty();
            $.each(bookLists, function (i, bookList) {
                $.each(bookDetailLists, function (j, bookDetailList) {
                    /*	console.log(bookDetailLists)*/
                    if (bookList.bookId == bookDetailList.id) {
                        var ismark = ''
                        if (bookList.isMarxProject == "1") {  // 是否属于马工程
                            ismark = '是'
                        } else if (bookList.isMarxProject == "0") {
                            ismark = '否'
                        }
                        var html = $('<tr> ' +
                            '<td>' + bookList.schoolName + '</td> ' +
                            '<td>' + bookDetailList.bookName + '</td> ' +
                            '<td>' + bookDetailList.outOfTheSociety + '</td>  <td>' + bookList.useVersion + '</td> ' +
                            '<td>' + bookList.userNumber + '</td> </tr>');
                        $(".bookTbody").append(html)
                    }
                })

            });
        }
        else {
            $(".bookPage").css("display", "none");
            $(".bookTbody").hide();
            $(".BooknoInfo").empty();
            var html = $('<div class="text-center warnDiv4" style="width: 100%;margin: 73px 0px;font-size: 14px" >无信息!</div>');
            $(".BooknoInfo").append(html)
        }
    }

}

// 得到教材使用信息选修课2
function searchBookson_fun2(res) {
    console.log(res);
    if (res.status == 'SUCCESS') {
        var bookLists = res.obj.content;
        sum = res.obj.totalElements;
        counts = sum / pagecount;
        if (bookLists.length != 0) {
            $(".xuanxiuBookTbody").show();
            $(".bookPage").css("display", "block");
            if (sum % pagecount == 0) {
                counts = parseInt(sum / pagecount);
            }
            else {
                counts = parseInt(sum / pagecount) + 1;
            }
            $(".bookPage").paging({
                pageNo: pageThis,
                totalPage: counts,
                totalSize: sum,
                callback: function (num) {
                    console.log(num);
                    index = num - 1;
                    getBookInfo2();
                    pageThis = num;
                }
            });
            $(".xuanxiuBookTbody").empty();
            $(".BooknoInfo").empty();

            $.each(bookLists, function (i, bookList) {
                $.each(bookDetailLists, function (j, bookDetailList) {
                    if (bookList.bookId == bookDetailList.id) {
                        var ismark = ''
                        if (bookList.isMarxProject == "1") {  // 是否属于马工程
                            ismark = '是'
                        } else if (bookList.isMarxProject == "0") {
                            ismark = '否'
                        }
                        var html = $('<tr> ' +
                            '<td>' + bookList.className + '</td> ' +
                            '<td><a  data-target="#myModalteachermes" onclick="showteacher(this)" data-teaid="' + bookList.teacherId + '">' + bookList.classTeacher + '</a></td> ' +
                            '<td>' + bookDetailList.bookName + '</td> ' +
                            '<td>' + bookDetailList.outOfTheSociety + '</td> <td>' + bookList.editor + '</td> <td>' + bookList.useVersion + '</td> ' +
                            '<td>' + ismark + '</td> ' +
                            '<td>' + bookList.userNumber + '</td> </tr>');
                        $(".xuanxiuBookTbody").append(html)
                    }
                })

            });
        }
        else {
            $(".bookPage").css("display", "none");
            $(".xuanxiuBookTbody").hide();
            $(".BooknoInfo").empty();
            var html = $('<div class="text-center" style="width: 100%;margin: 73px 0px;font-size: 14px" >无信息!</div>');
            $(".BooknoInfo").append(html)
        }
    }

}

// 得到教材名
function getBook() {
    var data = '{}';
    AjaxSubmit("GET", JSON.parse(data), BasePath + "schoolInfo/searchBook", searchBook_fun);
}
function searchBook_fun(res) {
    console.log(res);
    if (res.obj.content.length != 0) {
        bookDetailLists = res.obj.content;
        $(".BookSelect").empty();
        $(".BookSelect").append('<option data-bookId="">请选择</option>');
        $.each(bookDetailLists, function (i, bookDetailList) {
            if (bookid != "" && bookid != null & bookid != undefined) {
                if (bookid == bookDetailList.id) {
                    $(".BookSelect").append('<option data-bookId=' + bookDetailList.id + ' selected>' + bookDetailList.bookName + '</option>');
                } else {
                    $(".BookSelect").append('<option data-bookId=' + bookDetailList.id + '>' + bookDetailList.bookName + '</option>');
                }
            } else {
                $(".BookSelect").append('<option data-bookId=' + bookDetailList.id + '>' + bookDetailList.bookName + '</option>');
            }

        })
    } else {
        $(".BookSelect").append('<option data-bookId="">请选择</option>');
    }
}

// 得到学校名
function getSchoolName() {
    var data = '{"page":"' + index + '","size":"' + 10000 + '"}';
    AjaxSubmit("GET", JSON.parse(data), BasePath + "schoolInfo/searchSchool", searchSchool_fun);
}
function searchSchool_fun(res) {
    console.log(res);
    if (res.obj.content.length != 0) {
        schoolLists = res.obj.content;
        $(".schoolSelect").empty();
        $(".schoolSelect").append('<option data-schoolId="">请选择</option>');
        $.each(schoolLists, function (i, schoolList) {
            if (chooseSchoolName != "" && chooseSchoolName != null & chooseSchoolName != undefined) {
                if (chooseSchoolName == schoolList.id) {
                    $(".schoolSelect").append('<option data-schoolId=' + schoolList.id + ' selected>' + schoolList.schoolName + '</option>');
                } else {
                    $(".schoolSelect").append('<option data-schoolId=' + schoolList.id + '>' + schoolList.schoolName + '</option>');
                }
            } else {
                $(".schoolSelect").append('<option data-schoolId=' + schoolList.id + '>' + schoolList.schoolName + '</option>');
            }
        })
    } else {
        $(".schoolSelect").append('<option data-schoolId="">请选择</option>');
    }
}

// 得到学年
function getSchoolYear() {
    var data = {page: index, size: 10000};
    AjaxSubmit("GET", data, BasePath + "schoolInfo/searchSchoolYear", searchSchoolYear_fun);
}
function searchSchoolYear_fun(res) {
    console.log(res);
    if (res.obj.content.length != 0) {
        var yearLists = res.obj.content;
        $(".CourseSchoolYear").empty();

        $.each(yearLists, function (i, yearList) {
            if (gongyearNum != "" && gongyearNum != null & gongyearNum != undefined) {
                if (gongyearNum == yearList.schoolYearNum) {
                    $(".CourseSchoolYear").append('<option data-yearnum=' + yearList.schoolYearNum + ' selected>' + yearList.schoolYear + '</option>');
                } else {
                    $(".CourseSchoolYear").append('<option data-yearnum=' + yearList.schoolYearNum + '>' + yearList.schoolYear + '</option>');
                }
            } else {
                $(".CourseSchoolYear").append('<option data-yearnum=' + yearList.schoolYearNum + '>' + yearList.schoolYear + '</option>');
            }
        })
    }
}

//得到学年3
function getSchoolYear3() {
    var data = {page: index, size: 10000};
    AjaxSubmit2("GET", data, BasePath + "schoolInfo/searchSchoolYear", searchSchoolYear_fun3);
}
function searchSchoolYear_fun3(res) {
    console.log(res);
    if (res.obj.content.length != 0) {
        var yearLists = res.obj.content;
        $(".CourseSchoolYear1").empty();

        $.each(yearLists, function (i, yearList) {
            if (gongyearNum != "" && gongyearNum != null & gongyearNum != undefined) {
                if (gongyearNum == yearList.schoolYearNum) {
                    $(".CourseSchoolYear1").append('<option data-yearnum=' + yearList.schoolYearNum + ' selected>' + yearList.schoolYear + '</option>');
                } else {
                    $(".CourseSchoolYear1").append('<option data-yearnum=' + yearList.schoolYearNum + '>' + yearList.schoolYear + '</option>');
                }
            } else {
                $(".CourseSchoolYear1").append('<option data-yearnum=' + yearList.schoolYearNum + '>' + yearList.schoolYear + '</option>');
            }
        })
    }
}

// 得到学年2
function getSchoolYear2() {
    var data = {page: index, size: 10000};
    AjaxSubmit2("GET", data, BasePath + "schoolInfo/searchSchoolYear", searchSchoolYear_fun2);
}
function searchSchoolYear_fun2(res) {
    console.log(res);
    if (res.obj.content.length != 0) {
        var yearLists = res.obj.content;
        $(".CourseSchoolYear").empty();

        $.each(yearLists, function (i, yearList) {
            if (gongyearNum != "" && gongyearNum != null & gongyearNum != undefined) {
                if (gongyearNum == yearList.schoolYearNum) {
                    $(".CourseSchoolYear").append('<option data-yearnum=' + yearList.schoolYearNum + ' selected>' + yearList.schoolYear + '</option>');
                } else {
                    $(".CourseSchoolYear").append('<option data-yearnum=' + yearList.schoolYearNum + '>' + yearList.schoolYear + '</option>');
                }
            } else {
                $(".CourseSchoolYear").append('<option data-yearnum=' + yearList.schoolYearNum + '>' + yearList.schoolYear + '</option>');
            }
        })
    }
}

/* 得到课程名 */
function getCourseName() {
    var data = {page: index, size: 10000};
    AjaxSubmit("GET", data, BasePath + "schoolInfo/searchCourses", searchCourseName_fun);
}
function searchCourseName_fun(res) {
    console.log(res);
    if (res.obj.length != 0) {
        courseLists = res.obj;
        $(".courseSelect").empty();
        $(".courseSelect").append('<option data-courseId="">请选择</option>');
        $.each(courseLists, function (i, courseList) {
            if (coursesOffered != "" && coursesOffered != null & coursesOffered != undefined) {
                if (coursesOffered == courseList.id) {
                    $(".courseSelect").append('<option data-courseId=' + courseList.id + ' selected>' + courseList.courseName + '</option>');
                } else {
                    $(".courseSelect").append('<option data-courseId=' + courseList.id + '>' + courseList.courseName + '</option>');
                }
            } else {
                $(".courseSelect").append('<option data-courseId=' + courseList.id + '>' + courseList.courseName + '</option>');
            }

        })
    } else {
        $(".courseSelect").append('<option data-courseId="">请选择</option>');
    }
}

// 看教师信息
function showteacher(btn) {
    $("#myModalteachermes").modal('show');
    var teaid = $(btn).attr("data-teaid");
    var data = '{"teacherId":"' + teaid + '"}';
    console.log(data)
    AjaxSubmit("GET", JSON.parse(data), BasePath + "schoolInfo/getTeacherById", getTeacherById_fun);
}
function getTeacherById_fun(res) {
    console.log(res);
    if (res.status == 'SUCCESS') {
        if (res.obj != null && res.obj != undefined && res.obj != "") {
            var sex = '';
            var school = res.obj.graduateSchool || '';
            var birthday = changeTime(res.obj.birthday) || '';
            var schoolyear = res.obj.schoolyear || '';
            var positional = '';
            var duties = '';
            if (res.obj.sex == 'M') {
                sex = '男'
            } else {
                sex = '女'
            }
            /* 职称分批 */
            if (res.obj.positional == "LECTURER") {
                positional = '讲师'
            } else if (res.obj.positional == "ASSOCIATE_PROFESSOR") {
                positional = '副教授'
            } else if (res.obj.positional == "PROFESSOR") {
                positional = '教授'
            }
            /* 学历分批 */
            var education = '';
            if (res.obj.education == "UNDERGRADUATE") {
                education = '本科'
            } else if (res.obj.education == "POSTGRADUATE") {
                education = '硕士'
            } else if (res.obj.education == "DOCTOR") {
                education = '博士'
            }
            /* 职务分批 */
            if (res.obj.duties == "YUAN_ZHANG(") {
                duties = '院长'
            } else if (res.obj.duties == "FU_YUAN_ZHANG") {
                duties = '副院长'
            } else if (res.obj.duties == "SHU_JI") {
                duties = '书记'
            } else if (res.obj.duties == "FU_SHU_JI") {
                duties = '副书记'
            } else if (res.obj.duties == "KE_YAN_SHI_ZHU_REN") {
                duties = '科研室主任'
            } else if (res.obj.duties == "XUE_KE_DAI_TOU_REN") {
                duties = '学科带头人'
            } else if (res.obj.duties == "WU") {
                duties = '无'
            }
            var researchDirection = res.obj.researchDirection || '';
            var awardWinning = res.obj.awardWinning || '';
            var phone = res.obj.phone || '';
            var email = res.obj.email || '';
            var teacherName = res.obj.teacherName || '';
            var representativeWorksPapers = res.obj.representativeWorksPapers || '';
            var schoolName = res.obj.schoolName || '';
            $(".teaname").text(teacherName);
            $(".teaxueli").text(education);
            $(".teaschool").text(schoolName);
            $(".teaxuewei").text(education);
            $(".teasex").text(sex);
            $(".tealastschool").text(school);
            $(".teabirthday").text(birthday);
            $(".teakeshi").text(schoolyear);
            $(".teazc").text(positional);
            $(".teazw").text(duties);
            $(".teadirect").text(researchDirection);
            $(".teahoror").text(awardWinning);
            $(".teadaibiao").text(representativeWorksPapers);
            $(".teaphone").text(phone);
            $(".teamail").text(email);
        }
    }
}
function showteacherbyteachername(btn) {
    $("#myModalteachermes").modal('show');
    var teaName = $(btn).attr("data-teaid");
    var data = '{"teacherName":"' + teaName + '"}';
    console.log(data)
    AjaxSubmit("GET", JSON.parse(data), BasePath + "schoolInfo/searchTeacher", getTeacherByTeacherName_fun);
}
function getTeacherByTeacherName_fun(res) {
    console.log(res);
    if (res.status == 'SUCCESS') {
        res.obj = res.obj.content[0];
        if (res.obj != null && res.obj != undefined && res.obj != "") {
            var sex = '';
            var school = res.obj.graduateSchool || '';
            var birthday = changeTime(res.obj.birthday) || '';
            var schoolyear = res.obj.schoolyear || '';
            var positional = '';
            var duties = '';
            if (res.obj.sex == 'M') {
                sex = '男'
            } else {
                sex = '女'
            }
            /* 职称分批 */
            if (res.obj.positional == "LECTURER") {
                positional = '讲师'
            } else if (res.obj.positional == "ASSOCIATE_PROFESSOR") {
                positional = '副教授'
            } else if (res.obj.positional == "PROFESSOR") {
                positional = '教授'
            }
            /* 学历分批 */
            var education = '';
            if (res.obj.education == "UNDERGRADUATE") {
                education = '本科'
            } else if (res.obj.education == "POSTGRADUATE") {
                education = '硕士'
            } else if (res.obj.education == "DOCTOR") {
                education = '博士'
            }
            /* 职务分批 */
            if (res.obj.duties == "YUAN_ZHANG(") {
                duties = '院长'
            } else if (res.obj.duties == "FU_YUAN_ZHANG") {
                duties = '副院长'
            } else if (res.obj.duties == "SHU_JI") {
                duties = '书记'
            } else if (res.obj.duties == "FU_SHU_JI") {
                duties = '副书记'
            } else if (res.obj.duties == "KE_YAN_SHI_ZHU_REN") {
                duties = '科研室主任'
            } else if (res.obj.duties == "XUE_KE_DAI_TOU_REN") {
                duties = '学科带头人'
            } else if (res.obj.duties == "WU") {
                duties = '无'
            }
            var researchDirection = res.obj.researchDirection || '';
            var awardWinning = res.obj.awardWinning || '';
            var phone = res.obj.phone || '';
            var email = res.obj.email || '';
            var teacherName = res.obj.teacherName || '';
            var representativeWorksPapers = res.obj.representativeWorksPapers || '';
            var schoolName = res.obj.schoolName || '';
            $(".teaname").text(teacherName);
            $(".teaxueli").text(education);
            $(".teaschool").text(schoolName);
            $(".teaxuewei").text(education);
            $(".teasex").text(sex);
            $(".tealastschool").text(school);
            $(".teabirthday").text(birthday);
            $(".teakeshi").text(schoolyear);
            $(".teazc").text(positional);
            $(".teazw").text(duties);
            $(".teadirect").text(researchDirection);
            $(".teahoror").text(awardWinning);
            $(".teadaibiao").text(representativeWorksPapers);
            $(".teaphone").text(phone);
            $(".teamail").text(email);
        } else {
            alert("无此教师信息！");
            location.reload();
        }
    }
}

//初始化字段
function initFiled(nid) {
    var list = objectList[nid];
    var htmls = "";

    for (i in list) {
        htmls += ' <li><input type="checkbox" data-filed="' + i + '" name="' + i + '" checked>' + list[i] + '</li>';
    }
    $(".chooseFiledUl").html(htmls);
    $(".chooseFiledUl").attr("data-type", nid);
}
function saveModule(btn) {
    var type = $(".chooseFiledUl").attr("data-type");
    console.log(type)
    if (type == "1") {// 导出学校基本信息
        var array = [];
        for (var i = 0; i < $("#chooseField").find("input[type='checkbox']:checked").length; i++) {
            var filed = $("#chooseField").find("input[type='checkbox']:checked").eq(i).attr("data-filed");
            array.push(filed);
        }
        console.log(array);
        gongyearNum = $(".CourseSchoolYear").eq(0).children("option:selected").attr("data-yearnum");
        gongScoolName = $(".searchName1").val() || '';
        var requestData1 = {yearNum: gongyearNum, schoolName: gongScoolName};
        /*     var baseModels1 = ["schoolName", "buildType", "graduateStudent", "masterNum", "doctorNum", "allTeacher", "requiredCourse", "electiveCourse", "practiceTeachingcount", "masterPosNum", "doctorPosNum", "lastUpdateTime"];*/
        var str = JSON.stringify(array);
        var form = $("<form></form>").attr("action", exportExcelUrl1).attr("method", "GET");
        form.append($("<input></input>").attr("type", "hidden").attr("name", "baseModel").attr("value", str));
        var formKeyValue = appendForm(requestData1);
        for (var i = 0; i < formKeyValue.key.length; i++) {
            form.append($("<input></input>").attr("type", "hidden").attr("name", formKeyValue.key[i]).attr("value", formKeyValue.value[i]));
        }
        form.appendTo('body').submit().remove();
        form.submit();
    } else if (type == "2") {// 导出学校教师信息
        var brray = [];
        for (var i = 0; i < $("#chooseField").find("input[type='checkbox']:checked").length; i++) {
            var filed = $("#chooseField").find("input[type='checkbox']:checked").eq(i).attr("data-filed");
            brray.push(filed);
        }
        console.log(brray);
        gongyearNum = $(".CourseSchoolYear").eq(1).children("option:selected").attr("data-yearnum");
        gongScoolName = $(".searchName2").val() || '';
        var requestData2 = {yearNum: gongyearNum, schoolName: gongScoolName};
        /* var baseModels2 = ["schoolName", "allTeacher", "professorNum", "associateProfessorNum", "lecturerNum", "doctorNum", "masterNum", "graduateStudent", "averageClassTime", "averageClassNumber"];*/
        var str = JSON.stringify(brray);
        var form = $("<form></form>").attr("action", exportExcelUrl2).attr("method", "GET");
        form.append($("<input></input>").attr("type", "hidden").attr("name", "baseModel").attr("value", str));
        var formKeyValue = appendForm(requestData2);
        for (var i = 0; i < formKeyValue.key.length; i++) {
            form.append($("<input></input>").attr("type", "hidden").attr("name", formKeyValue.key[i]).attr("value", formKeyValue.value[i]));
        }
        form.appendTo('body').submit().remove();
        form.submit();
    } else if (type == "3") {// 导出学校班级信息
        var brray = [];
        for (var i = 0; i < $("#chooseField").find("input[type='checkbox']:checked").length; i++) {
            var filed = $("#chooseField").find("input[type='checkbox']:checked").eq(i).attr("data-filed");
            brray.push(filed);
        }
        gongyearNum = $(".CourseSchoolYear").eq(2).children("option:selected").attr("data-yearnum");
        gongScoolName = $(".searchName3").val() || '';
        var requestData3 = {yearNum: gongyearNum, schoolName: gongScoolName};
        /*  var baseModels3 = ["schoolName", "claaAllNum", "count1", "count2", "count3"];*/
        var str = JSON.stringify(brray);
        var form = $("<form></form>").attr("action", exportExcelUrl3).attr("method", "GET");
        form.append($("<input></input>").attr("type", "hidden").attr("name", "baseModel").attr("value", str));
        var formKeyValue = appendForm(requestData3);
        for (var i = 0; i < formKeyValue.key.length; i++) {
            form.append($("<input></input>").attr("type", "hidden").attr("name", formKeyValue.key[i]).attr("value", formKeyValue.value[i]));
        }
        form.appendTo('body').submit().remove();
        form.submit();
    } else if (type == "4") {// 导出教师信息
        var brray = [];
        for (var i = 0; i < $("#chooseField").find("input[type='checkbox']:checked").length; i++) {
            var filed = $("#chooseField").find("input[type='checkbox']:checked").eq(i).attr("data-filed");
            brray.push(filed);
        }
        chooseSchoolName = $(".schoolSelect").eq(0).children("option:selected").attr("data-schoolId");
        education = $(".educationSelect").children("option:selected").attr("data-typeT");
        duties = $(".dutiesSelect").children("option:selected").attr("data-typeT");
        positional = $(".positionalSelect").children("option:selected").attr("data-typeT");
        coursesOffered = $(".courseSelect").children("option:selected").attr("data-courseId");
        keyword = $(".keyWord").val() || '';
        var requestData4 = {
            schoolId: chooseSchoolName,
            education: education,
            duties: duties,
            positional: positional,
            coursesOffered: coursesOffered,
            field1: keyword
        };
        /*  var baseModels4 = ["teacherName", "schoolName", "positional", "duties", "phone", "coursesOffered", "researchDirection"];*/
        var str = JSON.stringify(brray);
        var form = $("<form></form>").attr("action", exportExcelUrl4).attr("method", "GET");
        form.append($("<input></input>").attr("type", "hidden").attr("name", "baseModel").attr("value", str));
        var formKeyValue = appendForm(juge(requestData4));
        for (var i = 0; i < formKeyValue.key.length; i++) {
            form.append($("<input></input>").attr("type", "hidden").attr("name", formKeyValue.key[i]).attr("value", formKeyValue.value[i]));
        }
        form.appendTo('body').submit().remove();
        form.submit();
    } else if (type == "5") {// 导出课表信息
        var brray = [];
        for (var i = 0; i < $("#chooseField").find("input[type='checkbox']:checked").length; i++) {
            var filed = $("#chooseField").find("input[type='checkbox']:checked").eq(i).attr("data-filed");
            brray.push(filed);
        }
        starttime = $("#startTime").val();
        endtime = $("#endTime").val();
        weekday = $(".weekday").children("option:selected").text();
        weekday = weekday === "全部" ? "" : weekday;

        gongyearNum = $(".CourseSchoolYear").eq(3).children("option:selected").attr("data-yearnum");
        gongScoolName = $(".searchName4").val();
        var requestData5 = {
            schoolYearNum: gongyearNum,
            schoolName: gongScoolName,
            startTime: starttime,
            startTimeTo: endtime,
            classTime: weekday
        };
        /*  var baseModels5 = ["schoolName", "courseName", "requiredElective", "teacher", "classPlace", "startTime", "classTime", "credit", "choiceOfCoursesNumber", "isGraduateClazz"];*/
        var str = JSON.stringify(brray);
        var form = $("<form></form>").attr("action", exportExcelUrl5).attr("method", "GET");
        form.append($("<input></input>").attr("type", "hidden").attr("name", "baseModel").attr("value", str));
        var formKeyValue = appendForm(juge(requestData5));
        for (var i = 0; i < formKeyValue.key.length; i++) {
            form.append($("<input></input>").attr("type", "hidden").attr("name", formKeyValue.key[i]).attr("value", formKeyValue.value[i]));
        }
        form.appendTo('body').submit().remove();
        form.submit();
    } else if (type == "6") {// 导出教材使用   需要修改还未完成
        var brray = [];
        for (var i = 0; i < $("#chooseField").find("input[type='checkbox']:checked").length; i++) {
            var filed = $("#chooseField").find("input[type='checkbox']:checked").eq(i).attr("data-filed");
            brray.push(filed);
        }
        gongyearNum = $(".CourseSchoolYear1").eq(0).children("option:selected").attr("data-yearnum");
        chooseSchoolName = $(".schoolSelect").eq(1).children("option:selected").attr("data-schoolId");
        bookid = $(".BookSelect").children("option:selected").attr("data-bookId")
        var requestData6 = {
            bookId: bookid,
            schoolId: chooseSchoolName,
            requiredElective: requiredElective,
            schoolYearNum: gongyearNum
        };
        /*  var baseModels6 = ["className", "classTeacher", "bookName", "outOfTheSociety", "editor", "useVersion", "isMarxProject", "userNumber"];*/
        var str = JSON.stringify(brray);
        var form = $("<form></form>").attr("action", exportExcelUrl6).attr("method", "GET");
        form.append($("<input></input>").attr("type", "hidden").attr("name", "baseModel").attr("value", str));
        var formKeyValue = appendForm(juge(requestData6));
        for (var i = 0; i < formKeyValue.key.length; i++) {
            form.append($("<input></input>").attr("type", "hidden").attr("name", formKeyValue.key[i]).attr("value", formKeyValue.value[i]));
        }
        form.appendTo('body').submit().remove();
        form.submit();
    } else if (type == "7") {// 导出实践活动
        var brray = [];
        for (var i = 0; i < $("#chooseField").find("input[type='checkbox']:checked").length; i++) {
            var filed = $("#chooseField").find("input[type='checkbox']:checked").eq(i).attr("data-filed");
            brray.push(filed);
        }
        chooseSchoolName = $(".schoolSelect").eq(2).children("option:selected").attr("data-schoolId");
        starttime = $(".activityStart").val();
        endtime = $(".activityEnd").val();
        proname = $(".proname").val();

        var requestData7 = {schoolId: chooseSchoolName, date: starttime, dateTo: endtime, projectName: proname};
        console.log(requestData7)
        /* var requestData7 = {schoolId:chooseSchoolName}; */
        // var baseModels7 = ["projectName", "teacher", "studentNum", "credit", "date", "content"];
        var str = JSON.stringify(brray);
        var form = $("<form></form>").attr("action", exportExcelUrl7).attr("method", "GET");
        form.append($("<input></input>").attr("type", "hidden").attr("name", "baseModel").attr("value", str));
        var formKeyValue = appendForm(juge(requestData7));
        for (var i = 0; i < formKeyValue.key.length; i++) {
            form.append($("<input></input>").attr("type", "hidden").attr("name", formKeyValue.key[i]).attr("value", formKeyValue.value[i]));
        }
        form.appendTo('body').submit().remove();
        form.submit();
    } else if (type == "8") {
        var crray = [];
        for (var i = 0; i < $("#chooseField").find("input[type='checkbox']:checked").length; i++) {
            var filed = $("#chooseField").find("input[type='checkbox']:checked").eq(i).attr("data-filed");
            crray.push(filed);
        }
        gongyearNum = $(".CourseSchoolYear1").eq(0).children("option:selected").attr("data-yearnum");
        gongScoolName = $(".schoolSelect").eq(1).children("option:selected").attr("data-schoolId");
        bookid = $(".BookSelect").children("option:selected").attr("data-bookId")
        var requestData10 = {
            bookId: bookid,
            schoolId: gongScoolName,
            requiredElective: requiredElective,
            schoolYearNum: gongyearNum
        };
        /*var baseModels10 = ["schoolName", "classTeacher", "bookName", "outOfTheSociety", "useVersion", "userNumber"];*/
        var str = JSON.stringify(crray);
        var form = $("<form></form>").attr("action", exportExcelUrl6).attr("method", "GET");
        form.append($("<input></input>").attr("type", "hidden").attr("name", "baseModel").attr("value", str));
        var formKeyValue = appendForm(juge(requestData10));
        for (var i = 0; i < formKeyValue.key.length; i++) {
            form.append($("<input></input>").attr("type", "hidden").attr("name", formKeyValue.key[i]).attr("value", formKeyValue.value[i]));
        }
        form.appendTo('body').submit().remove();
        form.submit();
    }
    $("#chooseField").modal('hide');
}
// 导出学校基本信息
function schoolDetailExport(btn) {
    initFiled("1");
}
// 导出学校教师信息
function exportSchoolTea(btn) {
    initFiled("2");
}
// 导出学校班级信息
function exportSchoolClass(btn) {
    initFiled("3");
}
// 导出教师信息需修改
function exportTeacher(btn) {
    initFiled("4");
}
// 导出课表信息需修改
function exportCourse(btn) {
    initFiled("5");
}
// 导出教材
function exportBook(btn) {
    if ($(".must").hasClass("span-red")) {// 必修课
        initFiled("6");
    }
    else if ($(".may").hasClass("span-red")) {// 选修课
        initFiled("8");
    }
}

// 导出实践活动需修改
function exportActivity(btn) {
    initFiled("7");
}

function appendForm(requestData) {
    var keys = [];
    var values = [];
    for (var data in requestData) {
        if (requestData.hasOwnProperty(data)) {
            keys.push(data);
            values.push(requestData[data]);
        }
    }
    var formKeyValue = {
        key: keys,
        value: values
    }
    return formKeyValue;
}

function changeTime(timeStr) {
    var date = new Date(timeStr);
    var dateYear = date.getFullYear();
    var dateMonth = date.getMonth() + 1;
    var dateDay = date.getDate();
    var hour = date.getHours();
    var min = date.getMinutes();
    // var dateStr = dateYear + "年" + dateMonth + "月" + dateDay + "日 " + hour +
    // ":" + min;
    var dateStr = dateYear + "-" + dateMonth;
    return dateStr;
}// 转换时间

function changeTimeXinXi(timeStr) {
    var date = new Date(timeStr);
    var dateYear = date.getFullYear();
    var dateMonth = date.getMonth() + 1;
    var dateDay = date.getDate();
    var hour = date.getHours();
    var min = date.getMinutes();
    // var dateStr = dateYear + "年" + dateMonth + "月" + dateDay + "日 " + hour + ":" + min;
    var dateStr = dateYear + "-" + dateMonth + "-" + dateDay;
    // var dateStr = dateYear + "-" + dateMonth;
    return dateStr;
}// 转换时间

function juge(obj) {
    var result = {};
    for (i in obj) {
        if (obj[i] == null || obj[i] == "") {
            continue;
        }
        var value = obj[i];
        if (obj[i] == undefined) {
            value = "";
        }
        eval("result." + i + "='" + value + "'");
    }
    return result;
}